//
//  StarView.m
//  AXM---课上的
//
//  Created by qianfeng on 15/9/29.
//  Copyright (c) 2015年 LiuQing. All rights reserved.
//

#import "StarView.h"

@implementation StarView
{
    UIImageView * _backgroundImageView;//白色小星
    UIImageView * _foregroundImageView;//黄色小星
}

- (instancetype) init
{
    if(self = [super init]) {
        self.frame = CGRectMake(0, 0, 65, 23);
        
        _backgroundImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 65, 23)];
        _backgroundImageView.image = [UIImage imageNamed:@"StarsBackground"];
        [self addSubview:_backgroundImageView];
        
        _foregroundImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 65, 23)];
        _foregroundImageView.image = [UIImage imageNamed:@"StarsForeground"];
        //左停靠
        _foregroundImageView.contentMode = UIViewContentModeLeft;
        //超界裁切
        _foregroundImageView.clipsToBounds = YES;
        [self addSubview:_foregroundImageView];
    }
    return self;
}

- (void)setStarValue:(float)value
{
    float width = value * self.frame.size.width;
    _foregroundImageView.frame = CGRectMake(0, 0, width, 23);
}




/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
